﻿/******************************************************************************
* File description: cameraProvider.h
* Function: 利用QQuickImageProvider为前端提供摄像头画面
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/

#ifndef CAMERAPROVIDER_H
#define CAMERAPROVIDER_H

#include <QQuickImageProvider>
#include <QDebug>

#include <QTimer>
#include <QImage>
#include <QDialog>
#include "HKCamera/head/HCNetSDK.h"
#include <QThread>
#include <QQmlApplicationEngine>
#include <QMutex>
#include <logHelper/debugLog.h>


#ifdef Q_OS_WINDOWS
#include <windows.h>
#endif
#ifdef Q_OS_ANDROID
#endif
#ifdef Q_OS_LINUX
#include <unistd.h>
#endif

extern QQmlApplicationEngine* gQmlEngine;

class CameraImageProvider : public QObject, public QQuickImageProvider{
    Q_OBJECT
public:
    CameraImageProvider();
    QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;

    void    lock()   {
        _imageMutex.lock();
    }
    void    unlock() {
        _imageMutex.unlock();
    }


    QImage*     pm;
    QMutex      _imageMutex;

};




#endif // CAMERAPROVIDER_H
